package com.classloader;

import sun.misc.Launcher;

import java.net.URL;

/**
 * @author hong
 * @version 1.0
 * @description: 学习jdk classlaoder
 * @date 2022/4/16 16:17
 */
public class TestJDKClassLoader {
    public static void main(String[] args) {
        System.out.println(String.class.getClassLoader());
        System.out.println(com.sun.crypto.provider.DESKeyFactory.class.getClassLoader().getClass().getName());
        System.out.println(TestJDKClassLoader.class.getClassLoader().getClass().getName());
        System.out.println();
        ClassLoader appClassLoader = ClassLoader.getSystemClassLoader();
        ClassLoader extClassLoader = appClassLoader.getParent();
        ClassLoader bootStrapLoader = extClassLoader.getParent();
        System.out.println("this appClassLoader"+appClassLoader);
        System.out.println("this extClassLoader"+extClassLoader);
        System.out.println("this bootStrapLoader"+bootStrapLoader);
        System.out.println();

        System.out.println("bootstrapLoader加载文件有：");
        URL[] urLs = Launcher.getBootstrapClassPath().getURLs();
        for (int i = 0; i < urLs.length; i++) {
            System.out.println(urLs[i]);
        }

        System.out.println();
        System.out.println("extClassLoader加载以下文件：");
        System.out.println(System.getProperty("java.ext.dirs"));

        System.out.println();
        System.out.println("appClassLoader加载以下文件：");
        System.out.println(System.getProperty("java.class.path"));


    }
}
